package com.cskaoyan.service;

import com.cskaoyan.domain.MarketSystem;
import com.cskaoyan.domain.MarketSystemExample;
import com.cskaoyan.mapper.MarketSystemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class SystemConfigServiceImpl implements SystemConfigService{
    @Autowired
    MarketSystemMapper marketSystemMapper;
    @Override
    public Map<String, Object> listWxConfig() {
        MarketSystemExample example = new MarketSystemExample();
        example.createCriteria().andKeyNameLike("market_wx_%").andDeletedEqualTo(false);
        List<MarketSystem> systems = marketSystemMapper.selectByExample(example);
        Map<String, Object> data = systems.stream().collect(Collectors.toMap(MarketSystem::getKeyName, MarketSystem::getKeyValue));
        data.put("market_wx_share", Boolean.valueOf(String.valueOf(data.get("market_wx_share"))));

        return data;
    }
}
